//
//  RelatedEquipmentCell.m
//  AILock
//
//  Created by 谭亚明 on 2020/7/7.
//  Copyright © 2020 tym. All rights reserved.
//

#import "EquipmentRepairCell.h"
#import "UIImageView+YPImage.h"

@interface EquipmentRepairCell()

@property(nonatomic,weak) UIImageView *headImage;
@property(nonatomic,weak) UILabel *nameLab;

//@property(nonatomic,weak) UIImageView  *eleImage;
//@property(nonatomic,weak) UIImageView  *wifiImage;
//@property(nonatomic,weak) UIImageView  *bluImage;
//@property(nonatomic,weak) UIImageView  *connectionImage;


@property(nonatomic,weak) UILabel *repairBtn;
@end

@implementation EquipmentRepairCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}

-(void)setEquipMent:(EquipmentModel *)equipMent{
    [self.headImage yp_setImageUlr:[equipMent getEquipmentImage]];
    self.nameLab.text = equipMent.equipmentName;

}

-(void)initUI{
 
    UIImageView *head = [[UIImageView alloc] init];
    head.backgroundColor = rgba(246, 246, 246);
    head.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:head];
    self.headImage = head;
    
    TYMLabel *lab = [TYMLabel lb_text:@"sdfsfs" font:Font_Medium(15) color:rgba(74, 74, 74)];
    [self.contentView addSubview:lab];
    self.nameLab  = lab;
    
//    UIImageView *ele = [[UIImageView alloc] init];
//    ele.backgroundColor = [UIColor redColor];
//    [self.contentView addSubview:ele];
//    self.eleImage  = ele;
//
//    UIImageView *wifi = [[UIImageView alloc] init];
//    wifi.backgroundColor = [UIColor redColor];
//    [self.contentView addSubview:wifi];
//    self.wifiImage  = wifi;
//
//    UIImageView *blu = [[UIImageView alloc] init];
//    blu.backgroundColor = [UIColor redColor];
//    [self.contentView addSubview:blu];
//    self.bluImage  = blu;
//
//    UIImageView *contin = [[UIImageView alloc] init];
//    contin.backgroundColor = [UIColor redColor];
//    [self.contentView addSubview:contin];
//    self.connectionImage  = contin;
//
    
    UILabel *btn = [TYMLabel lb_text:@"报修" font:Font_Regular(10.5) color:rgba(74, 74, 74)];
    btn.textAlignment = NSTextAlignmentCenter;
    btn.layer.cornerRadius = 3;
    btn.layer.borderColor = rgba(74, 74, 74).CGColor;
    btn.layer.borderWidth = 1;
    [self.contentView addSubview:btn];
    self.repairBtn = btn;
    
    [self.headImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(CGSizeMake(98, 84));
        make.centerY.equalTo(self.contentView);
        make.left.mas_equalTo(0);
    }];

    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headImage.mas_right).offset(20);
        make.top.mas_equalTo(15);
    }];
    
//    [self.eleImage mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(self.nameLab.mas_left);
//        make.top.mas_equalTo(self.nameLab.mas_bottom).offset(11);
//        make.size.mas_equalTo(CGSizeMake(18, 18));
//    }];
//    
//    [self.wifiImage mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.size.mas_equalTo(CGSizeMake(18, 18));
//        make.left.mas_equalTo(self.eleImage.mas_right).offset(5);
//        make.centerY.mas_equalTo(self.eleImage);
//    }];
//
//    [self.bluImage mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.size.mas_equalTo(CGSizeMake(18, 18));
//        make.left.mas_equalTo(self.wifiImage.mas_right).offset(5);
//        make.centerY.mas_equalTo(self.eleImage);
//    }];
//
//    [self.connectionImage mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.size.mas_equalTo(CGSizeMake(18, 18));
//        make.left.mas_equalTo(self.bluImage.mas_right).offset(5);
//        make.centerY.mas_equalTo(self.eleImage);
//    }];
    
    [self.repairBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.headImage);
        make.size.mas_equalTo(CGSizeMake(55, 25));
        make.right.mas_equalTo(@(-15));
    }];
}

+(NSString*)identifier{
    return @"RelatedEquipmentCell";
}

+(CGFloat)cellForHeight{
    return 84;
}

-(void)setEquipMentModel:(EquipmentModel *)equipMentModel{
    
    [_headImage yp_setImageUlr:[equipMentModel getEquipmentImage]];
    _nameLab.text = equipMentModel.equipmentName;
    
}

@end
